package org.thanos.demo.service;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;


@Getter
@AllArgsConstructor
public enum TaskType {
    CRON(1),
    FIXED_RATE(2),
    FIXED_DELAY(3),
    ;

    private final Integer id;

    public static TaskType idOf(Integer id) {
        Optional<TaskType> filterResult = Arrays.stream(TaskType.values()).filter(item -> item.id.equals(id)).findAny();
        return filterResult.orElse(null);
    }
}
